%%%-------------------------------------------------------------------
%%% @author mirahs(2892727493@qq.com)
%%% @doc
%%%     配置管理器
%%% @end
%%%-------------------------------------------------------------------
-module(config_mgr).

-behaviour(gen_server).

-export([start_link/1]).

-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).


%%%===================================================================
%%% Spawning and gen_server implementation
%%%===================================================================

start_link(FileConf) ->
    gen_server:start_link({local, ?MODULE}, ?MODULE, [FileConf], []).


init([FileConf]) ->
    {ok, KeyVals} = file:consult(FileConf),
    [env_mgr:set(Key, Val) || {Key, Val} <- KeyVals],

    {ok, undefined}.

handle_call(_Request, _From, State) ->
    {reply, ok, State}.

handle_cast(_Request, State) ->
    {noreply, State}.

handle_info(_Info, State) ->
    {noreply, State}.

terminate(_Reason, _State) ->
    ok.

code_change(_OldVsn, State, _Extra) ->
    {ok, State}.
